﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GestorSQL.DAO.FileManager
{
    public class TextFile : AbstractFileManager
    {
        protected override void ConcreteSaveFile(FileInfo file, string information)
        {
            using (StreamWriter writer = file.CreateText())
            {
                writer.Write(information);
            }
        }

        protected override void ConcreteSaveAppendFile(FileInfo file, string information)
        {

            using (StreamWriter writer = File.AppendText(file.FullName))
            {
                writer.WriteLine(information);
            }

        }

        protected override string ConcreteOpenFile(FileInfo file)
        {
            string information = string.Empty;
            using (StreamReader reader = file.OpenText())
            {
                information = reader.ReadToEnd();
            }
            return information;
        }

        protected override string GetExtension()
        {
            return "txt";
        }
    }
}
